package com.nbcb.fund.service.impl;

import com.nbcb.fund.dao.ChinamutualFundDescriptionDao;
import com.nbcb.fund.dao.ChinamutualFundNavDao;
import com.nbcb.fund.entity.po.ChinamutualFundDescriptionPo;
import com.nbcb.fund.entity.po.ChinamutualFundNavPo;
import com.nbcb.fund.entity.vo.MyFundVo;
import com.nbcb.fund.service.ChinamutualFundDescriptionService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ChinamutualFundDescriptionServiceImpl implements ChinamutualFundDescriptionService {

    @Resource
    ChinamutualFundDescriptionDao chinamutualFundDescriptionDao;
    @Resource
    ChinamutualFundNavDao chinamutualFundNavDao;

    @Override
    public List<MyFundVo> selectByWindCodes(List<String> windCodes) {
        List<MyFundVo> myFundVoList = chinamutualFundDescriptionDao.selectByWindCodes(windCodes);
        for (MyFundVo myFundVo: myFundVoList) {
            ChinamutualFundNavPo oneByWindCode = chinamutualFundNavDao.getOneByWindCode(myFundVo.getFInfoWindcode());
            if (oneByWindCode != null){
                myFundVo.setFNavUnit(oneByWindCode.getFNavUnit());
            }
        }
        return myFundVoList;
    }

    @Override
    public ChinamutualFundDescriptionPo getByWindCode(String fInfoWindcode) {
        ChinamutualFundDescriptionPo chinamutualFundDescriptionPo = chinamutualFundDescriptionDao.getByWindCode(fInfoWindcode);
        return chinamutualFundDescriptionPo;
    }
}
